﻿//创建时间: 2010-12-19
//创建作者: 李 城
//功能说明: 用户操作 映射
//最后修改: 2010-12-19
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Reflection;
using TRPOP.Common;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.Plugin
{
    /// <summary>
    /// 后台用户身份验证 Builder
    /// </summary>
    public class IAdminUserAccess 
    {
        const string mstrpath = "TRPOP.CMS.UserManage";
        const string mstrclassName = "TRPOP.CMS.UserManage.PermissionAdminManage";
        public static IAdminUser GetInstance()
        {
            /*
             * lcheng 2011.07.07 缓存提取方式修改
             * 
            ICache oICache = ICacheAccess.GetInstance();
            if (oICache.IsExist(CacheKeys.Sys_IAdminUser) == false)
            {
//#if  IsDemo
//                IAdminUser oIAdminUser = (IAdminUser)Assembly.Load(mstrpath).CreateInstance("TRPOP.CMS.UserManage.DiscuszAdminManage");
//#else
//                IAdminUser oIAdminUser = (IAdminUser)Assembly.Load(mstrpath).CreateInstance(mstrclassName);
//#endif
                IAdminUser oIAdminUser = (IAdminUser)Assembly.Load(mstrpath).CreateInstance(mstrclassName);
                oICache.Save(CacheKeys.Sys_IAdminUser,
                               oIAdminUser,
                               SYSConfig.CahceSeconds);
                return oIAdminUser;
            }
            return (IAdminUser)oICache.Read(CacheKeys.Sys_IAdminUser);
            */
            return CacheHelper.GetByICache<IAdminUser>(
                    CacheKeys.Sys_IAdminUser,
                    SYSConfig.SystemVar_CahceSeconds,
                    ICacheAccess.GetInstance(),
                    () =>
                    {
                        return (IAdminUser)Assembly.Load(mstrpath).CreateInstance(mstrclassName);
                    }
            );
        }

    }
}
